function [w_st,cy1_st,cy2_st]=Maxstat_n(gamma,betta,pi1,pi2,ey1,ey2,eo1,eo2,v1aut,v2aut,n)

st = @(z)[utility(z(1),gamma)+betta*(pi1*utility(n*ey1+eo1-n*z(1),gamma)+(1-pi1)*utility(n*ey2+eo2-n*z(2),gamma))-v1aut;      % IC state 1
        utility(z(2),gamma)+betta*(pi1*utility(n*ey1+eo1-n*z(1),gamma)+(1-pi1)*utility(n*ey2+eo2-n*z(2),gamma))-v2aut];       % IC state 2 

Zst = fsolve(st,[0.2 0.2]);

cy1_st = Zst(1);      % consumption of old state 1
cy2_st = Zst(2);      % consumption of old state 2
w_st = pi1*utility(n*ey1+eo1-n*cy1_st,gamma)+pi2*utility(n*ey2+eo2-n*cy2_st,gamma); 

end
